﻿namespace question1
{

    public class Rectangle
    {
        private double length;
        private double width;
        public Rectangle(double length, double width)
        {
            this.length = length > 0 ? length : 0;
            this.width = width > 0 ? width : 0;
        }
        public double CalculatePerimeter()
        {
            return 2 * (length + width);
        }
        public double CalculateArea()
        {
            return length * width;
        }
        public double Length
        {
            get { return length; }
            set { length = value > 0 ? value : 0; }
        }
        public double Width
        {
            get { return width; }
            set { width = value > 0 ? value : 0; }
        }
    }

    public class Program
    {
        public static void Main()
        {
            Rectangle rect1 = new Rectangle(5, 3);

            Console.WriteLine("长方形:");
            Console.WriteLine($"长度: {rect1.Length}, 宽度: {rect1.Width}");
            Console.WriteLine($"周长: {rect1.CalculatePerimeter()}");
            Console.WriteLine($"面积: {rect1.CalculateArea()}\n");  
        }
    }

}
